<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>Text::Diff - Perform diffs on files and record sets - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of Text-Diff - MetaCPAN" href="https://metacpan.org/dist/Text-Diff/releases.rss" />
        <link rel="canonical" href="./Text::Diff.html" />
        <meta name="description" content="Perform diffs on files and record sets" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/Text::Diff" />
<meta name="twitter:title"       content="Text::Diff" />
<meta name="twitter:description" content="Perform diffs on files and record sets" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./Text::Diff.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of Text-Diff was released.">
      <span class="relatize">16 Aug 2017 18:41:19 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/Text-Diff">Text-Diff</a>
  </li>
  <li>
    Module version: 1.45
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/Text-Diff/source/lib/Text/Diff.pm">Source</a>
    (<a href="https://metacpan.org/dist/Text-Diff/source/lib/Text/Diff.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/Text-Diff/source/lib/Text">Browse</a>
    (<a href="https://metacpan.org/dist/Text-Diff/source/lib/Text?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/Text-Diff/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/Text-Diff/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/neilbowers/Text-Diff">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://rt.cpan.org/Public/Dist/Display.html?Name=Text-Diff">Issues</a>
      (14)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=Text-Diff+1.45" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Text-Diff.html?oncpan=1&amp;distmat=1&amp;version=1.45&amp;grade=2" style="color: #090">1744</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Text-Diff.html?oncpan=1&amp;distmat=1&amp;version=1.45&amp;grade=3" style="color: #900">1</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/T/Text-Diff.html?oncpan=1&amp;distmat=1&amp;version=1.45&amp;grade=4">1</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/NEILB/Text-Diff-1.45">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on Text-Diff who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 2
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/Text-Diff-1.45/index.html">84.79% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li>
      Perl: v5.6.0
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/Text-Diff/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/N/NE/NEILB/Text-Diff-1.45.tar.gz">
      Download (<span itemprop="fileSize">28.91KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FNEILB%2FText-Diff-1.45%2Flib%2FText%2FDiff.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Text-Diff/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/Text-Diff/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:Text-Diff">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="Text-Diff">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Text/Diff.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="NEILB/Text-Diff-1.45"
>1.45
  (NEILB on 2017-08-16)</option>
<option
  
  value="OVID/Text-Diff-1.41"
>1.41
  (OVID on 2011-04-17)</option>
<option
  
  value="OVID/Text-Diff-1.40"
>1.40
  (OVID on 2011-04-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.37"
>1.37
  (ADAMK on 2009-07-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.36_01"
>1.36_01 DEV
  (ADAMK on 2009-07-13)</option>
<option
  
  value="RBS/Text-Diff-0.35"
>0.35
  (RBS on 2002-08-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="NEILB/Text-Diff-1.44"
>1.44
  (NEILB on 2016-02-26)</option>
<option
  
  value="NEILB/Text-Diff-1.43"
>1.43
  (NEILB on 2015-08-21)</option>
<option
  
  value="NEILB/Text-Diff-1.42"
>1.42
  (NEILB on 2015-08-20)</option>
<option
  
  value="NEILB/Text-Diff-1.41_01"
>1.41_01 DEV
  (NEILB on 2015-06-02)</option>
<option
  
  value="RBS/Text-Diff-0.34"
>0.34
  (RBS on 2002-07-14)</option>
<option
  
  value="RBS/Text-Diff-0.33"
>0.33
  (RBS on 2002-07-08)</option>
<option
  
  value="RBS/Text-Diff-0.32"
>0.32
  (RBS on 2002-03-14)</option>
<option
  
  value="RBS/Text-Diff-0.31"
>0.31
  (RBS on 2002-02-06)</option>
<option
  
  value="RBS/Text-Diff-0.3"
>0.3
  (RBS on 2001-12-21)</option>
<option
  
  value="RBS/Text-Diff-0.11"
>0.11
  (RBS on 2001-12-10)</option>
<option
  
  value="RBS/Text-Diff-0.1"
>0.1
  (RBS on 2001-12-09)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/NEILB/Text-Diff-1.45/diff/' + encodeURIComponent(this.value) + '/lib/Text/Diff.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="NEILB/Text-Diff-1.45"
>1.45
  (NEILB on 2017-08-16)</option>
<option
  
  value="OVID/Text-Diff-1.41"
>1.41
  (OVID on 2011-04-17)</option>
<option
  
  value="OVID/Text-Diff-1.40"
>1.40
  (OVID on 2011-04-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.37"
>1.37
  (ADAMK on 2009-07-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.36_01"
>1.36_01 DEV
  (ADAMK on 2009-07-13)</option>
<option
  
  value="RBS/Text-Diff-0.35"
>0.35
  (RBS on 2002-08-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="NEILB/Text-Diff-1.44"
>1.44
  (NEILB on 2016-02-26)</option>
<option
  
  value="NEILB/Text-Diff-1.43"
>1.43
  (NEILB on 2015-08-21)</option>
<option
  
  value="NEILB/Text-Diff-1.42"
>1.42
  (NEILB on 2015-08-20)</option>
<option
  
  value="NEILB/Text-Diff-1.41_01"
>1.41_01 DEV
  (NEILB on 2015-06-02)</option>
<option
  
  value="RBS/Text-Diff-0.34"
>0.34
  (RBS on 2002-07-14)</option>
<option
  
  value="RBS/Text-Diff-0.33"
>0.33
  (RBS on 2002-07-08)</option>
<option
  
  value="RBS/Text-Diff-0.32"
>0.32
  (RBS on 2002-03-14)</option>
<option
  
  value="RBS/Text-Diff-0.31"
>0.31
  (RBS on 2002-02-06)</option>
<option
  
  value="RBS/Text-Diff-0.3"
>0.3
  (RBS on 2001-12-21)</option>
<option
  
  value="RBS/Text-Diff-0.11"
>0.11
  (RBS on 2001-12-10)</option>
<option
  
  value="RBS/Text-Diff-0.1"
>0.1
  (RBS on 2001-12-09)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/Algorithm::Diff" title="Algorithm::Diff" class="ellipsis">Algorithm::Diff</a></li>
  <li><a href="https://metacpan.org/pod/Exporter" title="Exporter" class="ellipsis">Exporter</a></li>
  <li><i class="ttip" title="dynamic_config enabled">and possibly others</i></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/Text::Diff/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=Text%3A%3ADiff">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=Text-Diff">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/NEILB/Text-Diff-1.45/view/lib/Text/Diff.pm">This version</a>
    </li>
    <li>
      <a href="./Text::Diff.html">Latest version</a>
    </li>
    <li>
<div class="plussers">
<div class="nav-header">++ed by:</div>
<div>
<a class="display-all" href="https://metacpan.org/author/ADAMJS"><img src="https://www.gravatar.com/avatar/62c7b6e864d6509cff5839543c676614?d=identicon&amp;s=20" title="ADAMJS" alt="ADAMJS"></a>
<a class="display-all" href="https://metacpan.org/author/PERLBOY"><img src="https://www.gravatar.com/avatar/8553a87a00c8d2efcd77fb16e6eb73c9?d=identicon&amp;s=20" title="PERLBOY" alt="PERLBOY"></a>
<a class="display-all" href="https://metacpan.org/author/KEEDI"><img src="https://www.gravatar.com/avatar/95f905a7a4ccc573c711e9d264c0fde8?d=identicon&amp;s=20" title="KEEDI" alt="KEEDI"></a>
<a class="display-all" href="https://metacpan.org/author/NFG"><img src="https://www.gravatar.com/avatar/c213a8d2a3c6b38edff1070418d7cda2?d=identicon&amp;s=20" title="NFG" alt="NFG"></a>
<a class="display-all" href="https://metacpan.org/author/AMBA"><img src="https://www.gravatar.com/avatar/d93157c066e9dd81581637226eec34a1?d=identicon&amp;s=20" title="AMBA" alt="AMBA"></a>
</div>
<!-- Display counts of plussers-->
<div>
    <a href="https://metacpan.org/dist/Text-Diff/plussers">7 PAUSE users</a>
</div>
<div>
    8 non-PAUSE users
</div>
</div>
    </li>
    <li>
<div id="metacpan_contributors">
  <div>
    <button class="btn-link"
      onclick="$(this).hide(); $('#metacpan_contributors ul').slideDown(); return false;"
    >and 1 contributors</button>
  </div>
  <ul style="display: none">
    <li class="contributor"
      data-cpan-author="ADAMK"
      data-contrib-email="adamk@cpan.org"
    >
      <a href="https://metacpan.org/author/ADAMK" class="cpan-author">
      <img class="gravatar" width="20" height="20" src="https://www.gravatar.com/avatar/884124d0169f41668fb3f948b2ba8b0a?d=identicon&amp;s=20" />
      Adam Kennedy
      </a>
    </li>
  </ul>
</div>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/NEILB" class="author-name">Neil Bowers</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/Text/Diff.pm&#39;" class="">
<option
  selected
  value="NEILB/Text-Diff-1.45"
>1.45
  (NEILB on 2017-08-16)</option>
<option
  
  value="OVID/Text-Diff-1.41"
>1.41
  (OVID on 2011-04-17)</option>
<option
  
  value="OVID/Text-Diff-1.40"
>1.40
  (OVID on 2011-04-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.37"
>1.37
  (ADAMK on 2009-07-16)</option>
<option
  
  value="ADAMK/Text-Diff-1.36_01"
>1.36_01 DEV
  (ADAMK on 2009-07-13)</option>
<option
  
  value="RBS/Text-Diff-0.35"
>0.35
  (RBS on 2002-08-27)</option>
<optgroup label="BackPAN">'
<option
  
  value="NEILB/Text-Diff-1.44"
>1.44
  (NEILB on 2016-02-26)</option>
<option
  
  value="NEILB/Text-Diff-1.43"
>1.43
  (NEILB on 2015-08-21)</option>
<option
  
  value="NEILB/Text-Diff-1.42"
>1.42
  (NEILB on 2015-08-20)</option>
<option
  
  value="NEILB/Text-Diff-1.41_01"
>1.41_01 DEV
  (NEILB on 2015-06-02)</option>
<option
  
  value="RBS/Text-Diff-0.34"
>0.34
  (RBS on 2002-07-14)</option>
<option
  
  value="RBS/Text-Diff-0.33"
>0.33
  (RBS on 2002-07-08)</option>
<option
  
  value="RBS/Text-Diff-0.32"
>0.32
  (RBS on 2002-03-14)</option>
<option
  
  value="RBS/Text-Diff-0.31"
>0.31
  (RBS on 2002-02-06)</option>
<option
  
  value="RBS/Text-Diff-0.3"
>0.3
  (RBS on 2001-12-21)</option>
<option
  
  value="RBS/Text-Diff-0.11"
>0.11
  (RBS on 2001-12-10)</option>
<option
  
  value="RBS/Text-Diff-0.1"
>0.1
  (RBS on 2001-12-09)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/Text-Diff">Text-Diff-1.45</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage four &#10;
          • 103 direct dependents &#10;          • 5509 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="15"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="Text-Diff-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="Text-Diff-1.45">
    <input type="hidden" name="author" value="NEILB">
    <input type="hidden" name="distribution" value="Text-Diff">
    <button type="submit" class="favorite highlight"><span>15</span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./Text::Diff.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite highlight">
<span>15</span> ++</a>
</div>
   / <span>Text::Diff</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./Text::Diff.html#NAME">NAME</a></li>
  <li><a href="./Text::Diff.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./Text::Diff.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./Text::Diff.html#OPTIONS">OPTIONS</a></li>
  <li><a href="./Text::Diff.html#Formatting-Classes">Formatting Classes</a>
    <ul>
      <li><a href="./Text::Diff.html#Text::Diff::Base">Text::Diff::Base</a></li>
      <li><a href="./Text::Diff.html#Text::Diff::Unified">Text::Diff::Unified</a></li>
      <li><a href="./Text::Diff.html#Text::Diff::Table">Text::Diff::Table</a></li>
      <li><a href="./Text::Diff.html#Text::Diff::Context">Text::Diff::Context</a></li>
      <li><a href="./Text::Diff.html#Text::Diff::OldStyle">Text::Diff::OldStyle</a></li>
    </ul>
  </li>
  <li><a href="./Text::Diff.html#LIMITATIONS">LIMITATIONS</a></li>
  <li><a href="./Text::Diff.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./Text::Diff.html#REPOSITORY">REPOSITORY</a></li>
  <li><a href="./Text::Diff.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./Text::Diff.html#COPYRIGHT">COPYRIGHT</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>Text::Diff - Perform diffs on files and record sets</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>    use Text::Diff;

    ## Mix and match filenames, strings, file handles, producer subs,
    ## or arrays of records; returns diff in a string.
    ## WARNING: can return B&lt;large&gt; diffs for large files.
    my $diff = diff &quot;file1.txt&quot;, &quot;file2.txt&quot;, { STYLE =&gt; &quot;Context&quot; };
    my $diff = diff \$string1,   \$string2,   \%options;
    my $diff = diff \*FH1,       \*FH2;
    my $diff = diff \&amp;reader1,   \&amp;reader2;
    my $diff = diff \@records1,  \@records2;

    ## May also mix input types:
    my $diff = diff \@records1,  &quot;file_B.txt&quot;;</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p><code>diff()</code> provides a basic set of services akin to the GNU <code>diff</code> utility. It is not anywhere near as feature complete as GNU <code>diff</code>, but it is better integrated with Perl and available on all platforms. It is often faster than shelling out to a system&#39;s <code>diff</code> executable for small files, and generally slower on larger files.</p>

<p>Relies on <a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a> for, well, the algorithm. This may not produce the same exact diff as a system&#39;s local <code>diff</code> executable, but it will be a valid diff and comprehensible by <code>patch</code>. We haven&#39;t seen any differences between <a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a>&#39;s logic and GNU <code>diff</code>&#39;s, but we have not examined them to make sure they are indeed identical.</p>

<p><b>Note</b>: If you don&#39;t want to import the <code>diff</code> function, do one of the following:</p>

<pre><code>   use Text::Diff ();

   require Text::Diff;</code></pre>

<p>That&#39;s a pretty rare occurrence, so <code>diff()</code> is exported by default.</p>

<p>If you pass a filename, but the file can&#39;t be read, then <code>diff()</code> will <code>croak</code>.</p>

<h1 id="OPTIONS">OPTIONS</h1>

<p><code>diff()</code> takes two parameters from which to draw input and a set of options to control its output. The options are:</p>

<dl>

<dt id="FILENAME_A,-MTIME_A,-FILENAME_B,-MTIME_B"><a id="FILENAME_A"></a><a id="FILENAME_A--MTIME_A--FILENAME_B--MTIME_B"></a>FILENAME_A, MTIME_A, FILENAME_B, MTIME_B</dt>
<dd>

<p>The name of the file and the modification time &quot;files&quot;.</p>

<p>These are filled in automatically for each file when <code>diff()</code> is passed a filename, unless a defined value is passed in.</p>

<p>If a filename is not passed in and FILENAME_A and FILENAME_B are not provided or are <code>undef</code>, the header will not be printed.</p>

<p>Unused on <code>OldStyle</code> diffs.</p>

</dd>
<dt id="OFFSET_A,-OFFSET_B"><a id="OFFSET_A"></a><a id="OFFSET_A--OFFSET_B"></a>OFFSET_A, OFFSET_B</dt>
<dd>

<p>The index of the first line / element. These default to 1 for all parameter types except ARRAY references, for which the default is 0. This is because ARRAY references are presumed to be data structures, while the others are line-oriented text.</p>

</dd>
<dt id="STYLE">STYLE</dt>
<dd>

<p>&quot;Unified&quot;, &quot;Context&quot;, &quot;OldStyle&quot;, or an object or class reference for a class providing <code>file_header()</code>, <code>hunk_header()</code>, <code>hunk()</code>, <code>hunk_footer()</code> and <code>file_footer()</code> methods. The two footer() methods are provided for overloading only; none of the formats provide them.</p>

<p>Defaults to &quot;Unified&quot; (unlike standard <code>diff</code>, but Unified is what&#39;s most often used in submitting patches and is the most human readable of the three.</p>

<p>If the package indicated by the STYLE has no <code>hunk()</code> method, <code>diff()</code> will load it automatically (lazy loading). Since all such packages should inherit from <code>Text::Diff::Base</code>, this should be marvy.</p>

<p>Styles may be specified as class names (<code>STYLE =&gt; &#39;Foo&#39;</code>), in which case they will be <code>new()</code>ed with no parameters, or as objects (<code>STYLE =&gt; Foo-&gt;new</code>).</p>

</dd>
<dt id="CONTEXT">CONTEXT</dt>
<dd>

<p>How many lines before and after each diff to display. Ignored on old-style diffs. Defaults to 3.</p>

</dd>
<dt id="OUTPUT">OUTPUT</dt>
<dd>

<p>Examples and their equivalent subroutines:</p>

<pre><code>    OUTPUT   =&gt; \*FOOHANDLE,   # like: sub { print FOOHANDLE shift() }
    OUTPUT   =&gt; \$output,      # like: sub { $output .= shift }
    OUTPUT   =&gt; \@output,      # like: sub { push @output, shift }
    OUTPUT   =&gt; sub { $output .= shift },</code></pre>

<p>If no <code>OUTPUT</code> is supplied, returns the diffs in a string. If <code>OUTPUT</code> is a <code>CODE</code> ref, it will be called once with the (optional) file header, and once for each hunk body with the text to emit. If <code>OUTPUT</code> is an <a href="https://metacpan.org/pod/IO::Handle">IO::Handle</a>, output will be emitted to that handle.</p>

</dd>
<dt id="FILENAME_PREFIX_A,-FILENAME_PREFIX_B"><a id="FILENAME_PREFIX_A"></a><a id="FILENAME_PREFIX_A--FILENAME_PREFIX_B"></a>FILENAME_PREFIX_A, FILENAME_PREFIX_B</dt>
<dd>

<p>The string to print before the filename in the header. Unused on <code>OldStyle</code> diffs. Defaults are <code>&quot;---&quot;</code>, <code>&quot;+++&quot;</code> for Unified and <code>&quot;***&quot;</code>, <code>&quot;+++&quot;</code> for Context.</p>

</dd>
<dt id="KEYGEN,-KEYGEN_ARGS"><a id="KEYGEN"></a><a id="KEYGEN--KEYGEN_ARGS"></a>KEYGEN, KEYGEN_ARGS</dt>
<dd>

<p>These are passed to <a href="https://metacpan.org/pod/Algorithm::Diff#traverse_sequences">&quot;traverse_sequences&quot; in Algorithm::Diff</a>.</p>

</dd>
</dl>

<p><b>Note</b>: if neither <code>FILENAME_</code> option is defined, the header will not be printed. If at least one is present, the other and both <code>MTIME_</code> options must be present or &quot;Use of undefined variable&quot; warnings will be generated (except on <code>OldStyle</code> diffs, which ignores these options).</p>

<h1 id="Formatting-Classes"><a id="Formatting"></a>Formatting Classes</h1>

<p>These functions implement the output formats. They are grouped in to classes so <code>diff()</code> can use class names to call the correct set of output routines and so that you may inherit from them easily. There are no constructors or instance methods for these classes, though subclasses may provide them if need be.</p>

<p>Each class has <code>file_header()</code>, <code>hunk_header()</code>, <code>hunk()</code>, and <code>footer()</code> methods identical to those documented in the <code>Text::Diff::Unified</code> section. <code>header()</code> is called before the <code>hunk()</code> is first called, <code>footer()</code> afterwards. The default footer function is an empty method provided for overloading:</p>

<pre><code>    sub footer { return &quot;End of patch\n&quot; }</code></pre>

<p>Some output formats are provided by external modules (which are loaded automatically), such as <a href="https://metacpan.org/pod/Text::Diff::Table">Text::Diff::Table</a>. These are are documented here to keep the documentation simple.</p>

<h2 id="Text::Diff::Base"><a id="Text"></a>Text::Diff::Base</h2>

<p>Returns &quot;&quot; for all methods (other than <code>new()</code>).</p>

<h2 id="Text::Diff::Unified"><a id="Text1"></a>Text::Diff::Unified</h2>

<pre><code>  --- A   Mon Nov 12 23:49:30 2001
  +++ B   Mon Nov 12 23:49:30 2001
  @@ -2,13 +2,13 @@
   2
   3
   4
  -5d
  +5a
   6
   7
   8
   9
  +9a
   10
   11
  -11d
   12
   13</code></pre>

<dl>

<dt id="Text::Diff::Unified::file_header"><a id="Text2"></a>Text::Diff::Unified::file_header</dt>
<dd>

<pre><code>  $s = Text::Diff::Unified-&gt;file_header( $options );</code></pre>

<p>Returns a string containing a unified header. The sole parameter is the <code>options</code> hash passed in to <code>diff()</code>, containing at least:</p>

<pre><code>  FILENAME_A  =&gt; $fn1,
  MTIME_A     =&gt; $mtime1,
  FILENAME_B  =&gt; $fn2,
  MTIME_B     =&gt; $mtime2</code></pre>

<p>May also contain</p>

<pre><code>  FILENAME_PREFIX_A    =&gt; &quot;---&quot;,
  FILENAME_PREFIX_B    =&gt; &quot;+++&quot;,</code></pre>

<p>to override the default prefixes (default values shown).</p>

</dd>
<dt id="Text::Diff::Unified::hunk_header"><a id="Text3"></a>Text::Diff::Unified::hunk_header</dt>
<dd>

<pre><code>  Text::Diff::Unified-&gt;hunk_header( \@ops, $options );</code></pre>

<p>Returns a string containing the heading of one hunk of unified diff.</p>

</dd>
<dt id="Text::Diff::Unified::hunk"><a id="Text4"></a>Text::Diff::Unified::hunk</dt>
<dd>

<pre><code>  Text::Diff::Unified-&gt;hunk( \@seq_a, \@seq_b, \@ops, $options );</code></pre>

<p>Returns a string containing the output of one hunk of unified diff.</p>

</dd>
</dl>

<h2 id="Text::Diff::Table"><a id="Text5"></a>Text::Diff::Table</h2>

<pre><code>  +--+----------------------------------+--+------------------------------+
  |  |../Test-Differences-0.2/MANIFEST  |  |../Test-Differences/MANIFEST  |
  |  |Thu Dec 13 15:38:49 2001          |  |Sat Dec 15 02:09:44 2001      |
  +--+----------------------------------+--+------------------------------+
  |  |                                  * 1|Changes                       *
  | 1|Differences.pm                    | 2|Differences.pm                |
  | 2|MANIFEST                          | 3|MANIFEST                      |
  |  |                                  * 4|MANIFEST.SKIP                 *
  | 3|Makefile.PL                       | 5|Makefile.PL                   |
  |  |                                  * 6|t/00escape.t                  *
  | 4|t/00flatten.t                     | 7|t/00flatten.t                 |
  | 5|t/01text_vs_data.t                | 8|t/01text_vs_data.t            |
  | 6|t/10test.t                        | 9|t/10test.t                    |
  +--+----------------------------------+--+------------------------------+</code></pre>

<p>This format also goes to some pains to highlight &quot;invisible&quot; characters on differing elements by selectively escaping whitespace:</p>

<pre><code>  +--+--------------------------+--------------------------+
  |  |demo_ws_A.txt             |demo_ws_B.txt             |
  |  |Fri Dec 21 08:36:32 2001  |Fri Dec 21 08:36:50 2001  |
  +--+--------------------------+--------------------------+
  | 1|identical                 |identical                 |
  * 2|        spaced in         |        also spaced in    *
  * 3|embedded space            |embedded        tab       *
  | 4|identical                 |identical                 |
  * 5|        spaced in         |\ttabbed in               *
  * 6|trailing spaces\s\s\n     |trailing tabs\t\t\n       *
  | 7|identical                 |identical                 |
  * 8|lf line\n                 |crlf line\r\n             *
  * 9|embedded ws               |embedded\tws              *
  +--+--------------------------+--------------------------+</code></pre>

<p>See <a href="https://metacpan.org/pod/Text::Diff::Table">Text::Diff::Table</a> for more details, including how the whitespace escaping works.</p>

<h2 id="Text::Diff::Context"><a id="Text6"></a>Text::Diff::Context</h2>

<pre><code>    *** A   Mon Nov 12 23:49:30 2001
    --- B   Mon Nov 12 23:49:30 2001
    ***************
    *** 2,14 ****
      2
      3
      4
    ! 5d
      6
      7
      8
      9
      10
      11
    - 11d
      12
      13
    --- 2,14 ----
      2
      3
      4
    ! 5a
      6
      7
      8
      9
    + 9a
      10
      11
      12
      13</code></pre>

<p>Note: <code>hunk_header()</code> returns only &quot;***************\n&quot;.</p>

<h2 id="Text::Diff::OldStyle"><a id="Text7"></a>Text::Diff::OldStyle</h2>

<pre><code>    5c5
    &lt; 5d
    ---
    &gt; 5a
    9a10
    &gt; 9a
    12d12
    &lt; 11d</code></pre>

<p>Note: no <code>file_header()</code>.</p>

<h1 id="LIMITATIONS">LIMITATIONS</h1>

<p>Must suck both input files entirely in to memory and store them with a normal amount of Perlish overhead (one array location) per record. This is implied by the implementation of <a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a>, which takes two arrays. If <a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a> ever offers an incremental mode, this can be changed (contact the maintainers of <a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a> and <code>Text::Diff</code> if you need this; it shouldn&#39;t be too terribly hard to tie arrays in this fashion).</p>

<p>Does not provide most of the more refined GNU <code>diff</code> options: recursive directory tree scanning, ignoring blank lines / whitespace, etc., etc. These can all be added as time permits and need arises, many are rather easy; patches quite welcome.</p>

<p>Uses closures internally, this may lead to leaks on Perl versions 5.6.1 and prior if used many times over a process&#39; life time.</p>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="https://metacpan.org/pod/Algorithm::Diff">Algorithm::Diff</a> - the underlying implementation of the diff algorithm used by <code>Text::Diff</code>.</p>

<p><a href="https://metacpan.org/pod/YAML::Diff">YAML::Diff</a> - find difference between two YAML documents.</p>

<p><a href="https://metacpan.org/pod/HTML::Differences">HTML::Differences</a> - find difference between two HTML documents. This uses a more sane approach than <a href="https://metacpan.org/pod/HTML::Diff">HTML::Diff</a>.</p>

<p><a href="https://metacpan.org/pod/XML::Diff">XML::Diff</a> - find difference between two XML documents.</p>

<p><a href="https://metacpan.org/pod/Array::Diff">Array::Diff</a> - find the differences between two Perl arrays.</p>

<p><a href="https://metacpan.org/pod/Hash::Diff">Hash::Diff</a> - find the differences between two Perl hashes.</p>

<p><a href="https://metacpan.org/pod/Data::Diff">Data::Diff</a> - find difference between two arbitrary data structures.</p>

<h1 id="REPOSITORY">REPOSITORY</h1>

<p><a href="https://github.com/neilbowers/Text-Diff">https://github.com/neilbowers/Text-Diff</a></p>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Adam Kennedy &lt;adamk@cpan.org&gt;</p>

<p>Barrie Slaymaker &lt;barries@slaysys.com&gt;</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>Some parts copyright 2009 Adam Kennedy.</p>

<p>Copyright 2001 Barrie Slaymaker. All Rights Reserved.</p>

<p>You may use this under the terms of either the Artistic License or GNU Public License v 2.0 or greater.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install Text::Diff, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm Text::Diff</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install Text::Diff</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./Text::Diff.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
